package com.avic.rong.activity.product;

import android.content.Context;
import android.content.Intent;
import android.widget.TextView;

import com.avic.rong.BaseActivity;
import com.avic.rong.R;
import com.avic.rong.utils.SharedPreferencesUtil;
import com.example.minato.minastore.utils.AppUtils;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import wendu.dsbridge.DWebView;

public class PDFReaderActivity extends BaseActivity {


    public static final String ARG_KEYWORD = "keyword";

    @BindView(R.id.webview)
    DWebView webView;
    @BindView(R.id.tuijian)
    TextView tuijian;




    @Override
    protected int getContentViewId() {
        return R.layout.activity_pdf_reader;
    }


    @Override
    protected void initView() {

        ButterKnife.bind(this);


        tuijian.setText("PDF阅读");


        String keyWords = getIntent().getStringExtra(ARG_KEYWORD);
        webView.addJavascriptObject(this, null);
//        String url = AppUtils.BASE_URL + "appGood/" + skuIdStr;
//        webView.loadUrl(url);

//
//        webView.setWebViewClient(new MyWebViewClient(webView));


//        webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
//        webView.getSettings().setJavaScriptEnabled(true);
//        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);//适应内容大小
        try {
            webView.loadUrl(AppUtils.BASE_URL + "member/readOnline?token=" + URLEncoder.encode(SharedPreferencesUtil.getLoginToken(), "UTF-8") + "&bz=" + keyWords);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
//        webView.loadUrl("http://nm.rongrong.huazhi365.com/appGood/207556");

    }




    @Override
    protected void addListener() {

    }


    @OnClick(R.id.img_back)
    public void onBack(){
       onBackPressed();
    }




    public static Intent getIntent(Context context,String keyword){
        Intent intent = new Intent(context, PDFReaderActivity.class);
        intent.putExtra(ARG_KEYWORD, keyword);
        return intent;
    }









}
